/* file: tools.h */
#include "public.h"
#ifndef TOOLS_H
#define TOOLS_H

#define is_digit(c)   ((c)>='0'&&(c)<='9')                         /*  check digit       */
#define is_alpha(c)   ((c)>='a'&&(c)<='z'||(c)>='A'&&(c)<='Z')     /*  check alphabetic  */

int find_tab(char *);
void insert_tab(char *);

void print_token(token_type, const char *);
void print_variable(void);
void out_syn_tree(parser_tree *);

parser_tree *malloc_stmt(stmt_kind);
parser_tree *malloc_exp(exp_kind);

char *str_cpy(char *);

void free_tree(parser_tree *tree);

/* generate code */
static int asm_addr = 0;
void write_null(char *);
void write_in(void);
void write_mov_mem(int , char *);
void write_mov_reg(char *, int );
void write_out(void);
void save_curr_addr(int *);
void skip_curr_addr(void);
void write_jmp(char *, int);
void back_patch(int);
void mov_ax_num(int);
void write_push(void);
void write_pop(void);
void write_swap(void);
void write_cal(char *);

#endif
